<template>
	<!-- 此处返回是关闭当前页面，调整到指定页面。 -->
	<ls-page title=''>
		<view>
			<!-- 桌号 -->
			<view class="chxy-row-ac-end" style="display: flex;align-items: center;justify-content: space-between;">
				<text class="table-view">
					桌号：{{storeTableInfo.name}}
				</text>
				<view class="">
					合计:￥{{payTotalInfo.salePriceTotal}}
				</view>
			</view>

			<view class="h-20"></view>

			<!-- 组件、套餐商品与单品 -->
			<view>
				<package-goods :packageGoods="goodsList" :PriceTotal="payTotalInfo.salePriceTotal"
					:useGoldTotal="payTotalInfo.useGoldTotal">
				</package-goods>
			</view>

		   <!-- 支付方式 -->
		   <!-- <view class="h-60"></view> -->
		 <!--  <view class="pay-way-title">
		   	支付方式
		   </view> -->
		   <view class="h-40"></view>
		   <view class="pay-way-view" style="border-radius:16rpx 16rpx 0 0 ;">
		   	<!-- 正常直接 v-for -->
		   	<view @click="checkPayFun(3)" class="chxy-row-bt pay-wx-cell">
		   		<view class="chxy-row-ac">
		   			<image src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/type-wx.png"
		   				class="wx-cell-img"></image>
		   			<view class="wx-cell-name">微信支付</view>
		   		</view>
		   		<view>
		   			<image v-show='!payViewList[3].checkPay'
		   				src="https://oss.jtmckj.com/wmp/images/common/i_radio_check.png" class="w32h32"></image>
		   			<image v-show='payViewList[3].checkPay'
		   				:src=" themeInfo  =='001' ? 'https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/radio-check.png' : 'https://oss.jtmckj.com/h5-uniapp/tgx/order/radio-check.png' "
		   				class="w32h32"></image>
		   		</view>
		   	</view>
			<view @click="checkPayFun(1)" class="chxy-row-bt pay-amt-cell">
				<view class="chxy-row-ac">
					<image src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/type-vip.png"
						class="amt-img">
					</image>
					<view class="chxy-column-c-c">
						<view class="amt-lable-name">会员卡支付</view>
						<view class="h-10"></view>
						<view class="chxy-row-ac amt-right-view">
							<div>
								<div>本金：￥{{_FormatNumber(storeCardInfo.currentAmt)}}</div>
								<div>赠送：￥{{_FormatNumber(storeCardInfo.currentPresentAmt)}}</div>
								<!-- <div>本单可用赠送金额：￥{{_FormatNumber(payTotalInfo.prePayAmt)}}</div> -->
							</div>
							
							<view class="amt-right-check" v-if="payViewList[1].checkPay">
								<text>已抵扣：</text>
								<text class="amt-check-num">￥{{ payTotalInfo.memberPayDiff || 0}}</text>
							</view>
						</view>
					</view>
				</view>
				<view>
					<image v-show='!payViewList[1].checkPay'
						src="https://oss.jtmckj.com/wmp/images/common/i_checkbox_check.png" class="w32h32"></image>
					<image v-show='payViewList[1].checkPay'
					:src="themeInfo  =='001' ? 'https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/que-check.png' : 'https://oss.jtmckj.com/h5-uniapp/tgx/order/que-check.png' "
						class="w32h32"></image>
				</view>
			</view>
		   	<view @click="checkPayFun(2)" class="chxy-row-bt pay-ali-cell">
		   		<view class="chxy-row-ac">
		   			<image src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/type-ali.png"
		   				class="ali-cell-img"></image>
		   			<view class="ali-cell-name">支付宝支付</view>
		   		</view>
		   		<view>
		   			<image v-show='!payViewList[2].checkPay'
		   				src="https://oss.jtmckj.com/wmp/images/common/i_radio_check.png" class="w32h32"></image>
		   			<image v-show='payViewList[2].checkPay'
		   				:src=" themeInfo  =='001' ? 'https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/radio-check.png' : 'https://oss.jtmckj.com/h5-uniapp/tgx/order/radio-check.png' "
		   				class="w32h32"></image>
		   		</view>
		   	</view>
		   	<view @click="checkPayFun(0)" class="chxy-row-bt pay-gold-cell">
		   		<view class="chxy-row-ac">
		   			<image src="https://oss.jtmckj.com/wmp/images/order/i_icon_coin.png" class="gold-cell-img">
		   			</image>
		   			<view class="chxy-column-c-c">
		   				<view class="gold-cell-lable">金币支付</view>
		   				<view class="h-10"></view>
		   				<view class="chxy-row-ac gold-cell-right">
		   					可抵扣：￥{{ payTotalInfo.useGoldTotal || 0}}
		   					<view class="gold-right-check" v-if="payViewList[0].checkPay">
		   						<text>已抵扣：</text>
		   						<text class="gold-check-mun">￥{{ payTotalInfo.useGoldHad || 0}}</text>
		   					</view>
		   				</view>
		   			</view>
		   		</view>
		   		<view>
		   			<image v-show='!payViewList[0].checkPay'
		   				src="https://oss.jtmckj.com/wmp/images/common/i_checkbox_check.png" class="w32h32">
		   			</image>
		   			<image v-show='payViewList[0].checkPay'
		   				:src="themeInfo  =='001' ? 'https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/que-check.png' : 'https://oss.jtmckj.com/h5-uniapp/tgx/order/que-check.png' "
		   				class="w32h32">
		   			</image>
		   		</view>
		   	</view>
		
		   	
		   	<!-- 	<view @click="checkPayFun(4)" class="chxy-row-bt" style="height: 120rpx;margin: 0 24rpx;">
		   		<view class="chxy-row-ac">
		   			<image src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/type-df.png"
		   				style="height: 60rpx;width: 60rpx;margin-right: 24rpx;"></image>
		   			<view style="color: var(--maincolorf1);font-size:32rpx;font-weight: bold;">找人代付</view>
		   		</view>
		   		<view>
		   			<image v-show='!payViewList[4].checkPay'
		   				src="https://oss.jtmckj.com/wmp/images/common/i_radio_check.png"
		   				style="height: 32rpx;width: 32rpx;"></image>
		   			<image v-show='payViewList[4].checkPay'
		   				src="https://oss.jtmckj.com/wmp/kbq/common/i_radio_choose.png"
		   				style="height: 32rpx;width: 32rpx;"></image>
		   		</view>
		   	</view> -->
		   
		   </view>
		   <!-- 优惠券 -->
		   <view class="card-yhq-view" v-if="shopInfo.isUseTicket" style="border-radius: 0 0 16rpx 16rpx;">
		   	<view class="chxy-row-bt yhq-top-view">
		   		<view class="chxy-row-ac yhq-top-item" @click="showTickets">
		   			<view class="yhq-left">
		   				<image src="https://oss.jtmckj.com/wmp/images/home/orderPay/i_icon_coupon.png"
		   					class="yhj-img">
		   				</image>
		   				<view class="yhq-lable-name">优惠券</view>
		   			</view>
		   			<view class="yhq-center">
		   				<view class="center-ticket-total" v-if="payTotalInfo.ticketTotal">
		   					已抵扣：￥{{payTotalInfo.ticketTotal}}
		   				</view>
		   				<view class="center-desc" v-if="!canUseTicketNum">暂无可用优惠券</view>
		   				<view class="center-ticket-num" v-if="canUseTicketNum && !payTotalInfo.ticketTotal">
		   					有{{ canUseTicketNum }}张优惠券可用
		   				</view>
		   				<image class="center-img"
		   					src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/right-icon.png">
		   				</image>
		   			</view>
		   		</view>
		   	</view>
		   	<!-- 优惠券list -->
		  	<view class="chxy-row-bt yhq-list-view" v-for="(v,k) in selectedTickets" :key="k">
		   		<view class="list-name">{{v.TicketName}}</view>
		   		<image @click="delTikect(v,k)" class="list-img"
		   			src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/close-icon.png">
		   		</image>
		   	</view>
		   	<view class="h-24"></view>
		   </view>
		   <view class="h-10"></view>
			<!-- 品牌卡 -->
	<!-- 		<view class="card-view">
				<up-image width="702rpx" height="320rpx" :src="storeCardInfo.backgroundAtt2" mode="scaleToFill">
				</up-image>
				<view class="card-name-view">
					<view class="card-left-name">
						{{storeCardInfo.carName}}
					</view>
					<view class="card-center-code">
						NO.{{storeCardInfo.code}}
					</view>
				</view>
				<view @tap="$u.throttle(changeCard(storeCardInfo), 500)" class="chxy-row-ac card-right-change"
					v-if="cardList && cardList.length > 1">
					<image src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/h5-uniapp/h5-order/changefff.png"
						class="card-change-img"></image>
					<view class="card-change-name">
						{{storeCardInfo.cardType == 2 ? '切换品牌卡' : '切换门店卡'}}
					</view>
				</view>
				<view class="card-vip-view">
					<view class="card-vip-amtact">{{storeCardInfo.currentAmtAct}}</view>
					<view class="chxy-row-bt card-vip-item">
						<view class="card-item-lable">
							<div class="card-send">本金:{{storeCardInfo.currentAmt}}</div>
							<div class="card-send">赠送:{{storeCardInfo.currentPresentAmt}}</div>
						</view>
						<view class="cz-color" :class="themeInfo == '001' ? 'qunqing' : 'other'" @click="toStore">立即储值</view>
					</view>
					<view class="chxy-row-ac card-vip-coins">
						<image src="https://oss.jtmckj.com/wmp/images/order/i_icon_coin.png" class="h40w40"></image>
						<view class="m-l-16">金币余额：{{storeCardInfo.currentCoins}}</view>
					</view>
				</view>
			</view> -->

			<view class="h-20"></view>

			
			<useTicket v-if="ticketShow" :show="ticketShow" @update:show="ticketShow = $event"
				@finishPay="confirmTicket" :info="tickInfo" :vipInfo="ticketIsVip" :payInfo="payTotalInfo" />
			<!-- <yhj-pop/> -->

			
			<view class="h-20"></view> 
			<!-- 推荐储值 -->   
			<!-- 当前付款的商品金额，  推荐的金额需要大于当前付款金额，推荐金额没有大于的话 ， 默认选择第一个 -->
			<view class="" style="padding: 0 24rpx;">
				   <view class="tj-containr">
				   	      <view class="poa-text">
				   	      	     推荐充值
				   	      </view>
						  <view class="poa-gd">
						  	    <view class="poa-gd-text" @click="toStore">
						  	    	  更多
						  	    </view>
								<image style="width: 12rpx;height: 18rpx;" src="https://oss.jtmckj.com/pc/svgs/arrow-icon.png" mode=""></image>
						  </view>
						  <view class="" style="height: 75rpx;">
						  	
						  </view>
						  <view class="store-continar" v-for="(item,index) in storeProductList" :key="index">
						  	       <view class="store-flex">
						  	       	      <image class="store-img" src="https://oss.jtmckj.com/pc/svgs/store-icon.png" mode=""></image>
										  <view class="store-info">
											     <view class="store-title">
											     	{{item.Name}}
											     </view>
										  	     <view class="store-mark">
										  	     	{{item.Subtitle}}
										  	     </view>
										  </view>
						  	       </view>
								   <view class="select-conainr">
								   	         <view class="se-item-list" v-for="(v,k) in item.schemelist" :key="k" @click="selectProduct(k)">
								   	         	   <image class="se-icon" :src="selectedIndex === k ? 'https://oss.jtmckj.com/pc/svgs/active-icon.png' : 'https://oss.jtmckj.com/pc/svgs/select-icon.png'" mode=""></image>
												    <view class="radio-label">
												   <span class="se-name" v-for="(part, index) in splitName(v.Name)" :key="index">
												   {{ part }}
												   <!-- 如果不是最后一部分，插入换行符 -->
												   <span v-if="index < splitName(v.Name).length - 1" class="line-break"></span>
												   </span>
								   	         </view>
								   	         </view>
										
								   </view>
						  </view>
						  <view class="store-btn" @click="InstantStored">
						  	立即储值
						  </view>
						  
				   </view>
			</view>
	
			
			
			<view class="" style="padding: 0 24rpx;" v-if="!(orderPayType == 'unpay' || orderPayType == 'paying')">
						   <view class="" style="height: 100rpx;width: 100%;">
						   	      <u-textarea :maxlength="10" v-model="remark" placeholder="请输入备注"
						   	      	count></u-textarea>
						   </view>
			</view>
			<!-- 修复高度 -->
			<view class="fix-h-288"></view>

			<!-- 支付区域 -->
			<view class="min-consume-view chxy-row-c-c" v-if="calculateLowPrice > 0 && storeCardInfo.memberIsPayCard === '0'">
				低消{{ storeTableInfo.minConsume }}元，还差{{ calculateLowPrice }}元
			</view>
			
			<view class="min-consuhad-view chxy-row-c-c" v-if="calculateLowPrice > 0 && storeCardInfo.memberIsPayCard === '1'">
				低消{{ storeTableInfo.minConsume }}元，还差{{ calculateLowPrice }}元
			</view>

			<!-- memberIsPayCard 是否付费开卡 开卡之后才能享受会员价 1是 0否
            cardType 1品牌卡 2门店卡 isPayCard 1可以升级权益卡 0不能升级权益卡 -->
			<benefit-vip ref="benefitVipRef" :saleFiffVip='payTotalInfo.saleFiffVip' @updateVipFlag='updateVipFlag'
				v-if="canUpMember" v-show="storeCardInfo.memberIsPayCard == '0' && storeCardInfo.isPayCard =='1' ">
			</benefit-vip>

			<view class="pay-view chxy-row-c-c">
				<view>
					<view>
						<text class="pay-view-total">￥{{numAddFun(calculatePrice,payTotalInfo.totalPayVip)}}</text>
						<template v-if="storeCardInfo.memberIsPayCard == '1' ||  payTotalInfo.openVip"> 
									<text class="pay-view-dif" v-if="payTotalInfo.saleFiffVip > 0 && (shopInfo.isPriceVipPrice ? payViewList[1].checkPay : true)">
									(已优惠:{{payTotalInfo.saleFiffVip}}元)
									</text>
						</template>
					</view>
					<view class="pay-view-vip" v-show="payTotalInfo.totalPayVip > 0">
						含开通权益会员￥{{payTotalInfo.totalPayVip}}
					</view>
				</view>
				<!-- <view style="width: 180rpx;height: 80rpx;border-radius: 40rpx;border: 1rpx solid #666666;margin-left: 20rpx;line-height: 80rpx;font-size: 32rpx;color: var(--maincolorf2);text-align: center;">取消支付</view> -->
				<view class="w180"></view>
				<view class="to-pay-but" v-if="calculateLowPrice <= 0" @tap="$u.throttle(creatOrderPre, 500)">
					去支付
				</view>
				<view class="to-pay-but" v-else @click="showMin">
					去支付
				</view>
			</view>
			<x-popup class="uv-content" position="center" :show="showAliPay">
				<view class="uv-content-mask">
					<view class="mask-title">
						支付确认
					</view>
					<view class="mask-list">
						1、请点击"去支付",进入支付宝完成支付。
					</view>
					<view class="mask-list">
						2、如果您已支付或放弃支付，请点击"返回商家"。
					</view>
				</view>
				<view class="mask-btn">
					<view class="mask-cancle" @click.stop="payReturn">
						取消支付
					</view>
				</view>
				<uv-parse ref="uvParseRef" :content="aliContent"></uv-parse>
			</x-popup>
			<pay v-if="payShow" :show="payShow" @update:show="payShow = $event" @finishPay="confirmPay($event)" payto="store" :info="stroePayForm" />
		</view>
	</ls-page>
</template>

<script setup>
	import wx from 'weixin-js-sdk'
	import dayjs from 'dayjs';
	import { clearStoreGoodsNum } from "@/until/orderUtils.js"
	import { _FormatNumber } from '@/until/tools.js'
	import { computed } from 'vue'
	import { HFiveMemberAppObjProcess } from '@/api/public.js'
	import {
		onLoad,
		onShow,
		onHide,
		onPageScroll,
		onReachBottom,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import {
		ref,
		reactive,
		onMounted,
		nextTick,
		defineEmits,
		defineExpose,
		defineProps
	} from 'vue';
	import {
		initCardInfo,
		getCardInfoMore,
		getCardInfoUpdate,
		numMultiFun,
		numAddFun,
		numDiffFun,
		memberPayGive,
		payListFun,
		calculatePercentPrice
	} from "@/until/tools.js"
	import { useCartStore } from '@/store/cart.js';
	import { useCardStore } from '@/store/card.js';
	import { useTableStore } from '@/store/table.js';
	const storeTable = useTableStore();
	const storeCart = useCartStore();
	const storeCard = useCardStore();
	const shopInfo = uni.getStorageSync('shopInfo') || {};
	const cardList = ref([])
	const orderPayType = ref('') // ''正常买单 unpay已点订单未支付  paying已点订单支付中
	const canUpMember = ref(true)

	const benefitVipRef = ref()
	const storeTableInfo = ref({}) // 桌台信息
	const storeCardInfo = ref({}) // 卡信息 
	const goodsModal = ref({}) // 购车商品信息
	const goodsList = ref([]) // 购车商品信息
	const tickInfo = ref({}) // 优惠券信息
	const ticketShow = ref(false) // 优惠券弹窗
	const selectedTickets = ref([])
	const showAliPay = ref(false) // 支付宝支付弹窗显示
	const aliContent = ref('') // 支付宝支付渲染内容
	
	
	const uvParseRef = ref(null)
	
	// 支付数据总对象   
	const payTotalInfo = ref({
		"bookAmt": 0, // 预订押金
		"bookPayType": '', // 预订押金支付方式
		"payBookAmt": 0, // 本次支付使用的预订押金
		"bookCardNo": '', // 预订押金的会员卡号（如果是用会员卡支付的）

		"ticketTotal": 0, // 优惠券已抵扣
		'memberTicketCode': '', // 优惠券编码

		'useGoldTotal': 0, //金币支付-可抵扣
		'useGoldHad': 0, //金币支付-已抵扣

		"memberPayDiff": 0, // 会员卡支付-已抵扣
		"prePayAmt": 0, // 赠送金额 

		'salePriceTotal': 0,
		"vipPriceTotal": 0,
		'saleFiffVip': 0, // salePriceTotal与vipPriceTotal差价

		"payVip": 9.9, // 会员卡升级价格
		'totalPay': 0, // 实际要支付的总价格
		'totalPayVip': 0, // 开通vip要支付的并且要用微信（支付宝）支付才可以（如果要升级会员卡就是payVip，否则0）

		"openVip": false
	})
	const remark = ref('')

	// 计算底部剩余金额 
	const calculatePrice = computed(() => {
		console.log(payTotalInfo.value);
		if (storeCardInfo.value.memberIsPayCard == '1' || payTotalInfo.value.openVip) { // 权益价格
			console.log(payViewList.value);
			if(shopInfo.isPriceVipPrice){ // 如果开启需要有会员余额才能享受权益价
				if(payViewList.value[1].checkPay){ // 判断是否选中会员卡（支付必须要有会员卡才能享受权益价）
					return Number(_FormatNumber(payTotalInfo.value.vipPriceTotal - payTotalInfo.value.memberPayDiff -
						payTotalInfo.value.useGoldHad - payTotalInfo.value.ticketTotal - payTotalInfo.value
						.payBookAmt))
				}else{
					return Number(_FormatNumber(payTotalInfo.value.salePriceTotal - payTotalInfo.value.memberPayDiff -
						payTotalInfo.value.useGoldHad - payTotalInfo.value.ticketTotal - payTotalInfo.value
						.payBookAmt))
				}
			}else{
				return Number(_FormatNumber(payTotalInfo.value.vipPriceTotal - payTotalInfo.value.memberPayDiff -
					payTotalInfo.value.useGoldHad - payTotalInfo.value.ticketTotal - payTotalInfo.value
					.payBookAmt))
			}
			
			
		} else { // 原价
			return Number(_FormatNumber(payTotalInfo.value.salePriceTotal - payTotalInfo.value.memberPayDiff -
				payTotalInfo.value.useGoldHad - payTotalInfo.value.ticketTotal - payTotalInfo.value
				.payBookAmt))
		}

	})

	// // 本单优惠的价格
	const calculateYhPrice = computed(() => {
		return Number(_FormatNumber(payTotalInfo.value.salePriceTotal - payTotalInfo.value.vipPriceTotal))
	})

	// // 低消差额
	const calculateLowPrice = computed(() => {
		console.log(storeTableInfo.value);
		console.log(lowConsume.value);
		if (isCountMinConsume.value) { // 要计算低消
			console.log(Number(_FormatNumber(storeTableInfo.value.minConsume - lowConsume.value)));
			return Number(_FormatNumber(storeTableInfo.value.minConsume - lowConsume.value))
		} else {
			return 0
		}
	})

	// 支付方式
	const payViewList = ref([{
		'index': 0,
		'name': '金币支付',
		'checkPay': false
	}, {
		'index': 1,
		'name': '会员卡支付',
		'checkPay': false
	}, {
		'index': 2,
		'name': '支付宝支付',
		'checkPay': false
	}, {
		'index': 3,
		'name': '微信支付',
		'checkPay': false
	}, {
		'index': 4,
		'name': '找人代付',
		'checkPay': false
	}])
	const lowConsume = ref(0) // 商品计入低消的总额
	const themeInfo = ref(uni.getStorageSync('themeInfo')?.type)
	onLoad( async (options) => {
		await initData(options)
		getstoreListStatus()
		checkPayFun(3) // 默认选中微信支付
	})

	onShow(() => {
		cardList.value = uni.getStorageSync('cardList')
		if(uni.getStorageSync('payAli')){
			uni.reLaunch({
				url: `/pages/order/index` // 跳转到订单详情
			})
			uni.removeStorageSync('payAli')
		}
	})

	const initData = async (options) => {
		onInit(options)
		await initCardInfoFun()
		initTableInfoFun()
		initGetMemberTicket() // 获取优惠券
		initGetMinConsume()
		clearSelect() // 清空选择方式  计算赠送金额
		getBookAmt() // 获取预订押金
	}
	// 页面初始化
	const onInit = (options) => {
		// 上一个页面是否点击了vip
		if (options.isPreVip) {
			payTotalInfo.value.openVip = options.isPreVip === 'true' ? true : false
		}
		// 获取商品信息
		goodsList.value = JSON.parse(decodeURIComponent(options.goodsList));

		lowConsume.value = 0
		goodsList.value.forEach(item => {
			if(item.itemType == '1'){
				updateFlavor(item)
			}
			if (item.isJoinMinConsume && (item.itemType == '1' || item.itemType == '2')) {
				lowConsume.value += Number(item.orderQty) * Number(item.salePrice)
			}
		})
		console.log(goodsList.value);
		if (uni.getStorageSync('orderPayInfo')) {
			orderPayType.value = uni.getStorageSync('orderPayInfo').orderPayType
		}
		calculatePercentPrice(goodsList.value) // 计算套餐比例价格
		console.log('goodsList.value:', goodsList.value)
	}
	const updateFlavor = (obj)=> {  // 规格
	    const { flavor, uomName } = obj;
	    if(!flavor || !uomName){
	        return obj
	    }
	    // 判断flavor中是否包含uomName
	    if (flavor.includes(uomName)) {
	    // 删除flavor中的uomName部分并修整字符串，去掉前后的逗号和空格
	    obj.flavor = flavor
	        .replace(uomName, '') // 删除uomName
	        .replace(/、\s*$/, '') // 如果结尾有逗号，去掉
	        .replace(/^\s*、/, '') // 如果开头有逗号，去掉
	        .trim(); // 删除前后的空格
	    }
	
	    return obj;
	}
	// 桌台信息
	const initTableInfoFun = () => {
		storeTableInfo.value = storeTable.GetTableInfo() // 取缓存桌台信息
		console.log('缓存获取：', storeTable.GetTableInfo())
		console.log(storeTableInfo.value);
	}

	// 卡信息
	const initCardInfoFun = async () => {
		cardList.value = await getCardInfoMore() // 获取所有会员卡
	
		uni.setStorageSync('cardList', cardList.value)
		storeCardInfo.value = uni.getStorageSync('cardInfo')
		cardList.value.forEach((item) => {
			if (storeCardInfo.value.code == item.code) {
				if(shopInfo.isPriceVipPrice){  // isPriceVipPrice是否要有会员余额才可享受权益会员
					if(item.currentAmtAct > 0 && item.memberIsPayCard == 1){
						item.memberIsPayCard = '1'
					}else{
						item.memberIsPayCard = '0'
					}
				}
				storeCardInfo.value = item
				uni.setStorageSync('cardInfo',item)
			}
		})
		// 赋值当前卡(根据之前的页面卡)
		
		console.log('storeCardInfo.value:', storeCardInfo.value)
		if (payTotalInfo.value.openVip) {
			payTotalInfo.value.totalPayVip = storeCardInfo.value.payCardAmt
		} else {
			payTotalInfo.value.totalPayVip = 0
		}
		initGoodsModal() // 初始化商品信息
	}
	const getBookAmt = () => { // 获取赠送金额
		HFiveMemberAppObjProcess({
			functionName: "GetRoomReserveState_H5",
			contentData: {
				roomCode: uni.getStorageSync('tableInfo')?.code
			}
		}).then((res) => {
			// console.log(res, 'res'); 
			if (res.isUseReserveAmt == false && res.reserveAmt > 0) { //true 已抵扣 false 未抵扣  false可以用
				payTotalInfo.value.bookAmt = res.reserveAmt
				payTotalInfo.value.bookPayType = res.posPayType
				payTotalInfo.value.bookCardNo = res.cardNo
				if (payTotalInfo.value.totalPay >= res.reserveAmt) { // 已点商品金额超过押金金额
					payTotalInfo.value.payBookAmt = res.reserveAmt
				} else {
					payTotalInfo.value.payBookAmt = payTotalInfo.value.totalPay
				}
			}
		})
	}

	const isCountMinConsume = ref(false) // 是否要验证低消
	// 获取低消
	const initGetMinConsume = async () => {
		console.log(storeTableInfo.value.consumeCode);
		if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 下单和买单的不要计算低消
			isCountMinConsume.value = false
			return
		}
		HFiveMemberAppObjProcess({
				"functionName": "CheckConsumeState_H5",
				"contentData": {
					consumeCode: storeTableInfo.value.consumeCode
				}
			})
			.then(res => {
				console.log(res);
				// isMinConsume=true 已经达到最低消费 false 未达到最低消费
				if (!res.isMinConsume) {
					isCountMinConsume.value = true //未到点最低消费 要计算低消
				}
				// isMinConsume=true 已经达到最低消费 false 未达到最低消费
				// if (!res.isMinConsume && !wx.getStorageSync('ISPAY_UN')) {
				//   this.setData({
				//     isCountMinConsume: true
				//   })
				// } 
			})
	}

	// 获取本单可用优惠券
	const canUseTicketNum = ref(0)
	const initGetMemberTicket = async () => {
		let arr = goodsList.value.filter(item=>item.itemType != 3)
	
		const orderDetails = JSON.stringify(arr)
		// return
		tickInfo.value = await HFiveMemberAppObjProcess({
			functionName: "GetUseMemberTicket_H5",
			contentData: {
				memberCarCode: storeCardInfo.value.code,
				consumeCode: storeTableInfo.value.consumeCode,
				orderDetails,
				isVip: (storeCardInfo.value.memberIsPayCard == '1' || payTotalInfo.value.openVip) ? true :
					false
			},
		})
		console.log(tickInfo.value);
		if (tickInfo.value && tickInfo.value.TicketList) {

			let useList = [];
			let notList = [];
			tickInfo.value.TicketList.map((e) => {
				if (e.IsUse == true) {
					useList.push(e);
				} else {
					notList.push(e);
				}
			})
			canUseTicketNum.value = useList.length
		}
	}
	const ticketIsVip = ref(false)
	const showTickets = () => {
		ticketShow.value = true

		let memberIsPayCard = false
		if (storeCardInfo.value.memberIsPayCard == '1' || payTotalInfo.value.openVip) {
			memberIsPayCard = true
		}
		ticketIsVip.value = memberIsPayCard
		
		// 选完优惠券  要把选中的其它支付取消 让用户重新选择支付方式
		payViewList.value.forEach(item=>{
			item.checkPay = false
		})
		payTotalInfo.value.memberPayDiff = 0
		payTotalInfo.value.useGoldHad  = 0
		
	}

	// 选中优惠券
	const confirmTicket = (payInfo, selectedCoupon) => {
		
		payTotalInfo.value = payInfo
		// 优惠券优先级 比预订押金高  如果优惠券够付 就不用押金
		couponToPreAmt()
		console.log(payTotalInfo.value)
		console.log(selectedCoupon);
		selectedTickets.value = selectedCoupon
		
		
	}
	// 删除优惠券
	const delTikect = (v, k) => {
		payTotalInfo.value.ticketTotal -= v.deductionAmt
		selectedTickets.value.splice(k, 1);
		// 优惠券优先级 比预订押金高  如果优惠券够付 就不用押金
		couponToPreAmt()
	}

	const couponToPreAmt = () => {
		// 优惠券优先级 比预订押金高  如果优惠券够付 就不用押金
		if (payTotalInfo.value.ticketTotal >= payTotalInfo.value.totalPay) {
			payTotalInfo.value.payBookAmt = 0
		} else {
			if (payTotalInfo.value.totalPay - payTotalInfo.value.ticketTotal > payTotalInfo.value.bookAmt) {
				payTotalInfo.value.payBookAmt = payTotalInfo.value.bookAmt
			} else {
				payTotalInfo.value.payBookAmt = payTotalInfo.value.totalPay - payTotalInfo.value.ticketTotal
			}
		}
	}

	const showMin = () => {
		uni.showToast({
			title: '点单商品金额达不到低消',
			icon: "none",
		});
	}

	// 商品信息 （合并需要创建订单信息 需要调整结构这里操作）
	const initGoodsModal = () => {

		goodsModal.value = {
			"functionName": "MemberOrderAdd_H5",
			"contentData": {
				"orderBatchCode": "",
				"roomCode": uni.getStorageSync('tableInfo').code,
				"orderTime": uni.$u.timeFormat(Date.now(), 'yyyy-mm-dd h:MM:ss'),
				"memberCode": uni.getStorageSync('userInfo').userCode, // userId
				"remark": remark.value,
				"detail": goodsList.value,
			}
		}
		let salePriceT = 0
		let vipPriceT = 0
		let useGoldT = 0
		goodsList.value.forEach((item, index) => {
			if (item.itemType != 3) {
				if (item.isUseGold == "1") {
					if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) {
						useGoldT = numAddFun(useGoldT, numMultiFun(item.orderQty, item.vipPrice))
					} else {
						useGoldT = numAddFun(useGoldT, numMultiFun(item.orderQty, item.salePrice))
					}
				}
				salePriceT = numAddFun(salePriceT, numMultiFun(item.orderQty, item.salePrice))
				vipPriceT = numAddFun(vipPriceT, numMultiFun(item.orderQty, item.vipPrice))
			}
		})
		payTotalInfo.value.useGoldTotal = useGoldT
		payTotalInfo.value['salePriceTotal'] = salePriceT
		payTotalInfo.value['vipPriceTotal'] = vipPriceT
		payTotalInfo.value.saleFiffVip = numDiffFun(salePriceT, vipPriceT)
		payTotalInfo.value['coinTotal'] = 0
		// 已经升级升级权益
		if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) {
			payTotalInfo.value['totalPay'] = vipPriceT
		} else {
			// 未升级权益或者没权益权限
			payTotalInfo.value['totalPay'] = salePriceT
		}
		if (goodsModal.value && goodsModal.value.contentData && payTotalInfo.value.totalPay == 0) {
			goodsModal.value.contentData.totalAmt = 0

			// 零元商品不要升级权益卡（零元商品直接下单，不会走买单，没法升级）
			canUpMember.value = false
			payTotalInfo.value.totalPayVip = 0
			payTotalInfo.value.openVip = false
		}
		nextTick(() => {
			if (payTotalInfo.value.openVip) {
				benefitVipRef.value.initStatus(true)
			} else {
				benefitVipRef.value.initStatus(false)
			}
		})
		console.log('payTotalInfo.value:', payTotalInfo.value)

	}

	// 创建订单前的规则 （1勾选支付方式 （优惠券不够全部支付））
	const payFlag = ref(false)
	const creatOrderPre = () => {
		uni.showLoading({
		    title: '支付中，请稍等',
		    mask: true, // 显示遮罩层
		    maskClickable: false // 遮罩层不可点击
		});
		// 请选择支付方式
		// 请选择权益卡升级支付方式
		// 请勾选额外的支付方式
		// 请选择升级权益卡支付方式
		// 微信支付金额不能为0
		// 他人代付金额不能为0
		// console.log('Number(payTotalInfo.value.totalPay) ',Number(payTotalInfo.value.totalPay) )
		// console.log('Number(payTotalInfo.value.totalPay) ',Number(payTotalInfo.value.totalPayVip) )
		// || numAddFun(payTotalInfo.value.totalPay,(payTotalInfo.value.totalPayVip)) > 0  
		if (calculatePrice.value > 0 && !payViewList.value[2].checkPay && !payViewList.value[3].checkPay && !
			payViewList.value[4].checkPay) {
			uni.showToast({
				title: '请选择支付方式',
				icon: 'none'
			})
			return
		}
		console.log(payTotalInfo.value.totalPayVip);
		console.log(payTotalInfo.value.openVip);
		console.log(payViewList.value[2].checkPay);
		console.log(payViewList.value[3].checkPay);
		if (payTotalInfo.value.totalPayVip > 0 && payTotalInfo.value.openVip && !payViewList.value[2].checkPay && !
			payViewList.value[3].checkPay) {
			uni.showToast({
				title: '升级权益卡请选择支付宝支付或微信支付',
				icon: 'none'
			})
			return
		}
		creatOrder() // 下单
	}
	
	// 套餐是否有子项校验
	const checkPackageCorrectness = (arr) =>{
	        // 记录所有 itemType == 2 的元素的 goodsPriceCode
	        const goodsPriceCodes = arr.filter(item => item.itemType == 2).map(item => item.goodsPriceCode);
	        // 如果没有 itemType == 2 的元素（没有套餐），直接返回套餐正确
	        if (goodsPriceCodes.length == 0) {
	            return true;
	        }
			
			let aa = true
			goodsPriceCodes.forEach(code => {
			  const match = arr.find(item => item.goodsPriceCode == code && item.itemType == 3);
			  
			  if (!match) {
			    aa = false
			  }
			});
			
			if(aa){
				return true;
			}
	    
	        return false;
	}

	// 创建订单（所有支付）
	const creatOrder = async () => {
		console.log(payFlag.value);
		console.log(goodsModal.value);
		if(goodsModal.value && goodsModal.value.contentData) {
		       goodsModal.value.contentData.remark  = remark.value
		}
		if (payFlag.value) {
			uni.showToast({
				title: '支付中，请稍等,或重新进入此页面',
				icon: 'none'
			})
			return
		}
		payFlag.value = true
		// unpay已点订单未支付  paying已点订单支付中
		if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 不下单
			let info = uni.getStorageSync('orderPayInfo')
			toPayType(info)
		} else {
			if(!(goodsModal.value.contentData && goodsModal.value.contentData.detail)){
				uni.showToast({
					title: '没有商品明显，请重新点单',
					icon: 'none'
				})
				payFlag.value = false
				return
			}
			let testArr = goodsModal.value.contentData.detail
			if(!checkPackageCorrectness(testArr)){
				uni.showToast({
					title: '套餐没有子项，请重新点单或联系服务员',
					icon: 'none'
				})
				payFlag.value = false
				return
			}
			
			let resultOrder = ''
			try {
				resultOrder = await HFiveMemberAppObjProcess(goodsModal.value)
				// 如果下单金额为零  不用买单
				if (goodsModal.value && goodsModal.value.contentData && goodsModal.value.contentData.totalAmt == 0) {
					uni.showToast({
						title: '下单成功',
						icon: 'none'
					})
					uni.reLaunch({
						url: `/pages/order/index` // 跳转到订单详情
					})
					return
				}
				console.log('resultOrder：', resultOrder)
				toPayType(resultOrder)
			} catch (error) {
				payFlag.value = false
			}
			
		
		}
	}

	// 过滤买单与临时买单的数据结构
	// const toPublicPaySelect = async (resultOrder, type) => {
	// 	let payType = 0
	// 	let publicPayModal = {
	// 		"functionName": "",
	// 		"contentData": {
	// 			"consumeCode": resultOrder.consumeCode,
	// 			"roomCode": storeTableInfo.value.code,
	// 			"payUser": "", // 不管
	// 			"payBatchCode": "", // 不管
	// 			"cashUser": "", // 不管
	// 			"detailList": resultOrder.dataList.map(item => item.itemCode).join(','), // itemCode逗号拼接 
	// 			"orderAmt": storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip ?
	// 				payTotalInfo.value.vipPriceTotal : payTotalInfo.value.salePriceTotal, // 380 不加9.9
	// 			"realPayAmt": storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip ?
	// 				payTotalInfo.value.vipPriceTotal : payTotalInfo.value.salePriceTotal, // 380 不加9.9 
	// 			"payList": payListFun(payViewList.value, payTotalInfo.value, goodsList.value),
	// 			"serviceAmt": [], // 不管
	// 			"memberCode": uni.getStorageSync('cardInfo').code, // 卡号
	// 			"memberTicketCode": payTotalInfo.value.memberTicketCode, // 优惠券编码 啥格式?
	// 			"isVip": storeCardInfo.memberIsPayCard === '1' || payTotalInfo.value.openVip ? true : false
	// 		}
	// 	}
	// 	if (type === 1) {
	// 		// 买单 = （金币支付/会员卡支付）
	// 		publicPayModal.functionName = "MemberOrderPay_H5"
	// 		toPublicPay(publicPayModal)
	// 	} else {
	// 		// 临时买单 = （微信或者支付宝后 执行的补充 金币支付/会员卡支付）
	// 		publicPayModal.functionName = "TemporaryOrderPay_H5"
	// 		toPublicPayLinshi(publicPayModal)
	// 	}
	// }

	// 预支付微信（获取微信支付参数）
	const toGetPayParam = async (resultOrder) => {
		// 支付参数
		let modalParam = {
			"functionName": "PayOrder_H5",
			"contentData": {
				"orderBatchCode": resultOrder.orderBatchCode,
				"roomCode": uni.getStorageSync('tableInfo').code, // "0017001", 
				"consumeCode": resultOrder.consumeCode,
				"fee": 200
			}
		}
		const payParam = await HFiveMemberAppObjProcess(modalParam)
		console.log('payParam：', payParam)
		wxPaySDK(payParam, resultOrder)
	}

	// 他人代付
	const otherReplacePay = (resultOrder) => {
		uni.showToast({
			title: '开发中~敬请期待~~~',
			icon: 'none'
		})
	}

	// 通用支付 （临时买单）
	const toPublicPayLinshi = async (publicPayModal) => {
		const publicPayRes = await HFiveMemberAppObjProcess(publicPayModal)
		console.log('publicPayResLinSin：', publicPayRes)
	}

	// 通用支付 （买单）
	const toPublicPay = async (publicPayModal) => {
		uni.showLoading({
			title: '支付中...'
		});
		const publicPayRes = await HFiveMemberAppObjProcess(publicPayModal)
		uni.hideLoading();
		console.log('publicPayRes：', publicPayRes)
		uni.showToast({
			title: '下单成功',
			icon: 'none'
		})
		// uni.reLaunch({
		// 	url: '/pages/home/index'
		// })
	}

	// 阿里支付
	// const aliPaySDK = (opt, resultOrder) => {
	// 	console.log(opt);
	// 	console.log(resultOrder);
	// 	return
	// 	// uni.showToast({ title: '开发中...敬请期待', icon: 'none' })
	// 	uni.navigateTo({
	// 		url: './alipay?payToken=' + 'token123456' + '&userId=' + '123456'
	// 	})
	// }
	// 微信支付(SDK) 
	const wxPaySDK = (opt, resultOrder) => {
		uni.setStorageSync('wxlink', 'order')
		let canCancle = '1'
		if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 不下单  不取消订单
			canCancle = '0'
		}
		uni.navigateTo({
		            url:'/pages/test/index?optModal=' + encodeURIComponent(JSON.stringify(opt)) + '&resultOrder='+encodeURIComponent(JSON.stringify(resultOrder)) + '&canCancle=' + canCancle
		        })
		payFlag.value = false
		return
		wx.config({
			debug: false, // 这里一般在测试阶段先用ture，等打包给后台的时候就改回false,
			appId: opt.appId, // 必填，公众号的唯一标识
			timestamp: opt.timeStamp, // 必填，生成签名的时间戳
			nonceStr: opt.nonceStr, // 必填，生成签名的随机串
			signature: opt.paySign, // 必填，签名
			jsApiList: ["chooseWXPay"] // 必填，需要使用的JS接口列表 
		});
		wx.ready(() => {
			wx.chooseWXPay({
				appId: opt.appId, // 必填，公众号的唯一标识
				timestamp: opt.timeStamp, // 必填，生成签名的时间戳
				nonceStr: opt.nonceStr, // 必填，生成签名的随机串
				package: opt.package, // 统一支付接口返回的prepay_id参数值，提交格式如:prepay_id=|*|*|*)
				signType: opt.signType, // 签名方式，根据后端返回就行，一般默认为'SHA1'，使用新版支付需传入'MD5'
				paySign: opt.paySign, // 必填，支付签名
				success: function(payRes) {
					
					// 支付成功后的回调函数
					console.log('success：', payRes)
					clearStoreGoodsNum() // 清空购物车
					uni.showToast({
						title: '支付成功',
						icon: 'none'
					})
					uni.reLaunch({
						url: `/pages/order/index` // 跳转到订单详情
					})
				},
				cancel: function(payRes) {
					// that.$message.error('取消支付')
					console.log('cancel：', payRes, opt, resultOrder)
					wxPayCancel(payRes, opt, resultOrder)
				},
				fail: function(payRes) {
					// that.$message.error('支付失败')
					console.log('fail：', payRes, opt, resultOrder)
					wxPayFail(payRes, opt, resultOrder)
				}
			});
		});
	}

	// 微信取消支付回调
	const wxPayCancel = (payRes, opt, resultOrder) => {
		// 取消订单
		let modalCancel = {
			"functionName": "MemberOrderCancel_H5",
			"contentData": {
				"orderBatchCode": resultOrder.orderBatchCode,
				"tradeNo": opt.tradeNo
			}
		}
		HFiveMemberAppObjProcess(modalCancel).then(res => {
			uni.showToast({
				title: '已取消支付',
				icon: 'none'
			})
		})
	}

	// 微信支付失败回调
	const wxPayFail = (payRes, opt, resultOrder) => {
		console.log(payRes, opt, resultOrder);
		let modalFail = {
			"functionName": "MenberCodePayQuery_H5",
			"contentData": {
				"OutTradeNo": opt.tradeNo,
				"PayType": '1'
			}
		}
		HFiveMemberAppObjProcess(modalFail).then(res => {
			uni.showToast({
				title: '下单成功',
				icon: 'none'
			})
			uni.reLaunch({
				url: `/pages/order/index` // 跳转到订单详情
			})
		}).catch(err => {
			// 取消订单
			let modalCancel = {
				"functionName": "MemberOrderCancel_H5",
				"contentData": {
					"orderBatchCode": resultOrder.orderBatchCode,
					"tradeNo": opt.tradeNo
				}
			}
			HFiveMemberAppObjProcess(modalCancel).then(res => {
				uni.showToast({
					title: '已取消支付',
					icon: 'none'
				})
			})
		})
	}

	const toStore = () => {
		uni.navigateTo({
			url: '/subpkg/view/centerStore/centerStore'
		})
	}

	// 切换卡
	const changeCard = async (nowCardInfo) => {
		// storeCardInfo.value = await getCardInfoMore(nowCardInfo)
		// uni.showLoading({
		// 	title: '切换中...'
		// });
		console.log(nowCardInfo);
		console.log(cardList.value, 'cardList.value');
		cardList.value.forEach((item) => {
			if (nowCardInfo.code !== item.code) {
				storeCardInfo.value = item
			}
		})
		storeCard.SetCardInfo(storeCardInfo.value)

		payViewList.value = payViewList.value.map(item => ({
			...item,
			checkPay: false
		}));
		// 清空选中开通vip
		payTotalInfo.value.openVip = false
		payTotalInfo.value.totalPayVip = 0
		if (payTotalInfo.value.openVip) {
			benefitVipRef.value.initStatus(true)
		} else {
			benefitVipRef.value.initStatus(false)
		}
		initGetMemberTicket() // 获取优惠券
		clearSelect()

	}
	// 清空选中的支付方式和优惠券 // 重新
	const clearSelect = () => {
		payTotalInfo.value.payBookAmt = 0
		payTotalInfo.value.ticketTotal = 0
		selectedTickets.value = []
		payTotalInfo.value.memberTicketCode = ''
		payTotalInfo.value.useGoldHad = 0
		payTotalInfo.value.memberPayDiff = 0
		let useGoldT = 0
		goodsList.value.forEach((item, index) => {
			if (item.isUseGold == "1") {
				if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) {
					useGoldT = numAddFun(useGoldT, numMultiFun(item.orderQty, item.vipPrice))
				} else {
					useGoldT = numAddFun(useGoldT, numMultiFun(item.orderQty, item.salePrice))
				}
			}
		})
		payTotalInfo.value.useGoldTotal = useGoldT
		if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) {
			payTotalInfo.value.totalPay = payTotalInfo.value.vipPriceTotal
			payTotalInfo.value.prePayAmt =
				memberPayGive(payTotalInfo.value.vipPriceTotal, storeCardInfo.value.currentAmt, storeCardInfo.value
					.currentPresentAmt, storeCardInfo.value.memberIsPayCard, payTotalInfo.value.openVip, goodsList
					.value)
		} else {
			payTotalInfo.value.totalPay = payTotalInfo.value.salePriceTotal
			payTotalInfo.value.prePayAmt =
				memberPayGive(payTotalInfo.value.salePriceTotal, storeCardInfo.value.currentAmt, storeCardInfo.value
					.currentPresentAmt, storeCardInfo.value.memberIsPayCard, payTotalInfo.value.openVip, goodsList
					.value)
		}
		// payTotalInfo.value ={
		//   "bookAmt": 0, // 预订押金
		//   "payBookAmt": 0, // 本次支付使用的预订押金

		//   "ticketTotal": 0, // 优惠券已抵扣
		//   'memberTicketCode': '', // 优惠券编码

		//   'useGoldTotal': 0, //金币支付-可抵扣
		//   'useGoldHad': 0, //金币支付-已抵扣

		//   "memberPayDiff": 0, // 会员卡支付-已抵扣
		//   "prePayAmt":0, // 赠送金额 

		//   'salePriceTotal': 0,
		//   "vipPriceTotal": 0,
		//   'saleFiffVip': 0, // salePriceTotal与vipPriceTotal差价
		//   "payVip": 9.9,
		//   'totalPay': 0, // 实际要支付的总价格
		//   'totalPayVip': 0, // 开通vip要支付的并且要用微信（支付宝）支付才可以
		//   "openVip": false
		// }
	}

	// 选中Vip权益
	const updateVipFlag = (checkFlag) => {
		console.log('checkFlag..：', checkFlag)
		payTotalInfo.value.openVip = checkFlag
		if (checkFlag) {
			payTotalInfo.value.totalPayVip = storeCardInfo.value.payCardAmt
			payTotalInfo.value.totalPay = payTotalInfo.value.vipPriceTotal
		} else {
			payTotalInfo.value.totalPayVip = 0
			payTotalInfo.value.totalPay = payTotalInfo.value.salePriceTotal
		}
		payViewList.value = payViewList.value.map(item => ({
			...item,
			checkPay: false
		}));
		clearSelect()
		tickInfo.value = {}
		initGetMemberTicket()
	}

	// 选择支付方式
	// "ticketTotal":0, // 优惠券已抵扣 
	// 'useGoldTotal': 0, //金币支付-可抵扣
	// 'useGoldHad': 0, //金币支付-已抵扣 
	// "memberPayDiff":0, // 会员卡支付-已抵扣 
	// 'salePriceTotal': 0,
	// "vipPriceTotal": 0,
	// 'saleFiffVip': 0, // salePriceTotal与vipPriceTotal差价
	// "payVip": 9.9,
	// 'totalPay': 0, // 实际要支付的总价格
	// 'totalPayVip': 0, // 开通vip要支付的并且要用微信支付才可以
	// "openVip": false
	// 组合支付
	const vipNoPay = ref([])
	const checkPayFun = (chenkIndex) => {

		console.log(chenkIndex);
		console.log(selectedTickets.value);
		let cardInfo = uni.getStorageSync("cardInfo")
		// payViewList.value[chenkIndex].checkPay === false
		// ticketTotal 抵扣完totalPay 为0  
		if (Number(calculatePrice.value) == 0 && payTotalInfo.value.totalPayVip === 0 && payViewList.value[chenkIndex]
			.checkPay === false) {
			uni.showToast({
				title: '无需再选择其它支付方式',
				icon: 'none'
			})
			return
		}
		// if (chenkIndex === 0 && payTotalInfo.value.useGoldTotal <= 0 && payViewList.value[0].checkPay === false) {
		// 	uni.showToast({
		// 		title: '暂无金币抵扣',
		// 		icon: 'none'
		// 	})
		// 	return
		// }
		if (chenkIndex === 1 && cardInfo.currentAmt <= 0 && payViewList.value[1].checkPay === false) {
			// 如果是可以100%用赠送金额的  可以不要判断本金余额
			if(shopInfo.preAmtUseRule && shopInfo.preAmtUseRule.presentAmtUseType == '2' && shopInfo.preAmtUseRule.useRate == '100' || uni.getStorageSync('shopInfo').brandCode == '0004'){
				if(cardInfo.currentPresentAmt <= 0){
					uni.showToast({
						title: '暂无会员卡余额抵扣',
						icon: 'none'
					})
					return
				}
			}else{
				uni.showToast({
					title: '暂无本金余额抵扣',
					icon: 'none'
				})
				return
			}
		
		}
		// 先判断单选还是多选 多选： 优先金币可抵扣，会员卡，微信=代付  优惠券抵扣的payTotalInfo.value.ticketTotal
		// 会员条件
		const {
			vipPriceTotal,
			salePriceTotal,
			memberPayDiff,
			useGoldHad,
			ticketTotal,
			payBookAmt
		} = payTotalInfo.value

		let carPrice = 0
		if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) { // 权益价格
			carPrice = vipPriceTotal
		} else {
			carPrice = salePriceTotal
		}

		if (chenkIndex === 0 && !payViewList.value[0].checkPay) { // 选中金币
			if (cardInfo.currentCoins <= 0) {
				uni.showToast({
					title: '暂无金币可抵扣',
					icon: 'none'
				})
				return
			}

			if (carPrice - ticketTotal - payBookAmt >= payTotalInfo.value
				.useGoldTotal) { // 如果代付金额 大于 商品可抵扣金币 则按商品可抵扣金币来比较可抵扣金币
				// 如果商品可抵扣金币 大于 金币余额
				if (payTotalInfo.value.useGoldTotal >= cardInfo.currentCoins) {
					// 不够支付 取用户已有的所有金币
					payTotalInfo.value.useGoldHad = cardInfo.currentCoins

				} else { // 如果商品可抵扣金币 小于 金币余额 取商品可抵扣金币
					payTotalInfo.value.useGoldHad = payTotalInfo.value.useGoldTotal
				}
			} else { // 如果代付金额 小于 商品可抵扣金币 则按代付金额来比较可抵扣金币
				// 如果代付金额 大于 金币余额  取金币余额
				if ((carPrice - ticketTotal - payBookAmt) >= cardInfo.currentCoins) {
					// 不够支付 取用户已有的所有金币
					payTotalInfo.value.useGoldHad = cardInfo.currentCoins

				} else { // 如果代付金额 小于 金币余额  取代付金额
					payTotalInfo.value.useGoldHad = carPrice - ticketTotal - payBookAmt

				}

			}
			payViewList.value[0].checkPay = true
			if (payViewList.value[1].checkPay) { // 如果之前已经勾选会员余额支付
				payTotalInfo.value.memberPayDiff = carPrice - ticketTotal - payBookAmt - payTotalInfo.value.useGoldHad
			}
			if (payTotalInfo.value.useGoldHad >= (carPrice - ticketTotal - payBookAmt)) { // 金币够付 单选
				payTotalInfo.value.memberPayDiff = 0
				payViewList.value[1].checkPay = false
				payViewList.value[2].checkPay = false
				payViewList.value[3].checkPay = false
				payViewList.value[4].checkPay = false
			}

		} else if (chenkIndex === 1 && !payViewList.value[1].checkPay) { // 会员卡支付
			vipNoPay.value = []
			goodsList.value.forEach(item=>{
				if(item.isUseBalance == '0' && item.itemType != '3'){
					vipNoPay.value.push(item.goodsName)
				}
			})
			if(vipNoPay.value && vipNoPay.value.length >0){
				let title = vipNoPay.value.splice(',')
					uni.showToast({
						title: title + '不可用会员卡余额支付',
						icon: 'none'
					})
					return
			}
			
		
			let presentAmt = uni.getStorageSync("cardInfo")?.currentPresentAmt || 0
			let currentAmt = uni.getStorageSync("cardInfo").currentAmt || 0
			let memberIsPayCardFlag = false
			if (storeCardInfo.value.memberIsPayCard === "1") {
				memberIsPayCardFlag = true
			}
			// 会员卡 可抵扣的赠送金额
			// let giveNum = memberPayGive(payTotalInfo.value.totalPay, currentAmt, presentAmt, memberIsPayCardFlag,payTotalInfo.value.openVip, goodsList.value)
			// payTotalInfo.value.prePayAmt = giveNum

			const memP = Number(_FormatNumber(carPrice - ticketTotal - payBookAmt - useGoldHad)) // 剩余支付金额

			// 如果会员卡本金余额+本单可用赠送金额大于剩余支付金额  
			if (numAddFun(payTotalInfo.value.prePayAmt, uni.getStorageSync("cardInfo").currentAmt) >= memP) {
				console.log(memP);
				payTotalInfo.value.memberPayDiff = memP
				// (微信、他人代付取消选中)
				payViewList.value[2].checkPay = false
				payViewList.value[3].checkPay = false
				payViewList.value[4].checkPay = false

			} else {
				console.log(payTotalInfo.value);
				console.log(payTotalInfo.value.prePayAmt, uni.getStorageSync("cardInfo"));
				payTotalInfo.value.memberPayDiff = numAddFun(payTotalInfo.value.prePayAmt, uni.getStorageSync(
					"cardInfo").currentAmt)
			}
			payViewList.value[1].checkPay = true

		} else if (chenkIndex === 2 && !payViewList.value[2].checkPay) {
			payViewList.value[2].checkPay = true
			payViewList.value[3].checkPay = false
			payViewList.value[4].checkPay = false
		} else if (chenkIndex === 3 && !payViewList.value[3].checkPay) {
			payViewList.value[3].checkPay = true
			payViewList.value[2].checkPay = false
			payViewList.value[4].checkPay = false
		} else if (chenkIndex === 4 && !payViewList.value[4].checkPay) {
			payViewList.value[4].checkPay = true
			payViewList.value[2].checkPay = false
			payViewList.value[3].checkPay = false
		} else if (chenkIndex === 0 && payViewList.value[0].checkPay) {
			payTotalInfo.value.useGoldHad = 0
			payViewList.value[0].checkPay = false
		} else if (chenkIndex === 1 && payViewList.value[1].checkPay) {
			payTotalInfo.value.memberPayDiff = 0
			payViewList.value[1].checkPay = false
		} else if (chenkIndex === 2 && payViewList.value[2].checkPay) {
			payViewList.value[2].checkPay = false
		} else if (chenkIndex === 3 && payViewList.value[3].checkPay) {
			payViewList.value[3].checkPay = false
		} else if (chenkIndex === 4 && payViewList.value[4].checkPay) {
			payViewList.value[4].checkPay = false
		}

	}
	
	const cancleForm = ref({
		orderBatchCode:'',
		tradeNo:'',
	})
	const cancelFlag = ref(false)
	const payReturn = ()=>{
		uni.showLoading({
		    title: '取消中，请稍等',
		    mask: true, // 显示遮罩层
		    maskClickable: false // 遮罩层不可点击
		});
		if(cancelFlag.value){
			uni.showToast({
				title: '取消中，请稍等',
				icon: 'none'
			})
			return
		}
		uni.removeStorageSync('payAli', true)
		cancelFlag.value = true
		let modalCancel = {
			"functionName": "MemberOrderCancel_H5",
			"contentData": cancleForm.value
		}
		if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 不取消订单
			cancelFlag.value = false
			uni.hideLoading()
			uni.navigateBack()
			return
		}
		HFiveMemberAppObjProcess(modalCancel).then(res => {
			showAliPay.value = false
			cancelFlag.value = false
			uni.hideLoading()
			uni.showToast({
				title: '已取消支付',
				icon: 'none'
			})
			uni.navigateBack()
		}).catch(err=>{
			cancelFlag.value = false
			uni.hideLoading()
		})
	}
	
	// 支付方式 判定
	const toPayType = async (resultOrder) => {

		
		payTotalInfo.value.memberTicketCode = selectedTickets.value.map(item => item.Code).join(','); // 优惠券code赋值
		

		let patWayList = payViewList.value.filter(item => item.checkPay).map(item => item.name) // name 或者 index
		console.log(patWayList);
		// return
		const {
			vipPriceTotal,
			salePriceTotal,
			memberPayDiff,
			useGoldHad,
			ticketTotal,
			payBookAmt
		} = payTotalInfo.value

		// 微信或支付宝支付要调用
		let fee = 0 // 微信(支付宝)要付的金额
		let cardPrice = 0

		if (storeCardInfo.value.memberIsPayCard == '1' || payTotalInfo.value.openVip) {
			if(shopInfo.isPriceVipPrice){ // 如果开启需要有会员余额才能享受权益价
				if(payViewList.value[1].checkPay){ // 判断是否选中会员卡（支付必须要有会员卡才能享受权益价）
					cardPrice = vipPriceTotal
				}else{
					cardPrice = salePriceTotal
				}
			}else{
				cardPrice = vipPriceTotal
			}
			
		} else {
			cardPrice = salePriceTotal
		}

		fee = Number(_FormatNumber(cardPrice - payBookAmt - ticketTotal - useGoldHad - memberPayDiff))
		const payForm = {
			orderBatchCode: resultOrder.orderBatchCode,
			roomCode: storeTableInfo.value.code,
			consumeCode: resultOrder.consumeCode,
			openUnionPay:shopInfo.isOpenUnionPay ? '1' : '0', // 1开启银联支付  0 正常支付
			fee,
		};
		if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 不下单
			payForm.orderBatchCode = uni.getStorageSync('orderPayInfo').orderBatchCode
		}

		// 微信跟/支付宝 - 需要调用接口告诉后端开始支付了>>>做标记
		const postForm = {
			"consumeCode": resultOrder.consumeCode,
			"roomCode": storeTableInfo.value.code,
			"payUser": "", // 付款人(代付)，（服务员） - 传空
			"payBatchCode": "", //  批次号(首次买单为空,后续再买单将首次的批次号传入)
			"cashUser": "", // 收银员 - 传空
			"detailList": resultOrder.dataList.map(item => item.itemCode).join(','), // itemCode逗号拼接 
			"orderAmt": cardPrice, // 380 不加9.9
			"realPayAmt": cardPrice, // 380 不加9.9 
			"payList": [], // 支付方式
			"serviceAmt": [], // 权益价优惠放里面
			"memberCode": uni.getStorageSync('cardInfo').code, // 卡号
			"memberTicketCode": payTotalInfo.value.memberTicketCode, // 优惠券编码 啥格式?
			"isVip": storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip ? true : false,
			"expireTime": dayjs(resultOrder.expireTime).format('YYYY-MM-DD HH:mm:ss')
		}

		// payForm 的 payList 的数组元素
		const payListForm = {
			// 本条的付款金额 订单总价格（是不是会员都一样）
			totalAmt: 0,
			// 客人付款金额（现金可能大于点单金额,需要有找零和抹零,其他方式totalAmt == payAmt）
			payAmt: "",
			// 找零金额
			giveChange: 0,
			// 抹零金额
			smallChange: 0,
			// 会员卡号（会员付款）
			memberCode: uni.getStorageSync('cardInfo').code,
			// 会员姓名
			memberName: uni.getStorageSync('userInfo').name,
			// 电话
			memberMobile: uni.getStorageSync('userInfo').mobile,
			// openid
			memberOpenId: "",
			// 支付方式（001现金 002微信 003支付宝 004会员卡 005消费卷）
			payType: "",
		}

		// 如果享受权益会员  serviceAmt要加上会员折扣
		if (storeCardInfo.value.memberIsPayCard === '1' || payTotalInfo.value.openVip) {
			if(shopInfo.isPriceVipPrice){ // 如果开启需要有会员余额才能享受权益价
				if(payViewList.value[1].checkPay){ // 判断是否选中会员卡（支付必须要有会员卡才能享受权益价）
					postForm.serviceAmt.push({
						type: "会员折扣优惠",
						amt: Number(payTotalInfo.value.saleFiffVip)
					})
				}
			}else{
				postForm.serviceAmt.push({
					type: "会员折扣优惠",
					amt: Number(payTotalInfo.value.saleFiffVip)
				})
			}
			
		}

		//  --------------------------------------------------- 按顺序 --------------------------------------

		// 预订押金
		if (payTotalInfo.value.payBookAmt > 0) {
			postForm.payList.push({
				...payListForm,
				payType: payTotalInfo.value.bookPayType,
				totalAmt: payTotalInfo.value.payBookAmt,
				payAmt: payTotalInfo.value.payBookAmt,
				memberCode: payTotalInfo.value.bookCardNo,
				isReservePay: '1'
			});
		}
		// 优惠券
		if (payTotalInfo.value.memberTicketCode) {
			postForm.payList.push({
				...payListForm,
				payType: "004",
				totalAmt: 0,
				payAmt: 0,
				memberCode: uni.getStorageSync('cardInfo').code,
			});
		}
		// 金币
		if (payTotalInfo.value.useGoldHad > 0) {
			postForm.payList.push({
				...payListForm,
				payType: "013",
				totalAmt: Number(_FormatNumber(payTotalInfo.value.useGoldHad)),
				payAmt: Number(_FormatNumber(payTotalInfo.value.useGoldHad)),
				memberCode: uni.getStorageSync('cardInfo').code,
			});
		}
		// 会员卡
		if (payTotalInfo.value.memberPayDiff > 0) {
			postForm.payList = postForm.payList.filter(item => item.payType !== '004'); // 删除前面的优惠券生成004支付
			if (payTotalInfo.value.prePayAmt >= payTotalInfo.value.memberPayDiff) {
				postForm.payList.push({
					...payListForm,
					payType: "004",
					prePayAmt: Number(_FormatNumber(payTotalInfo.value.memberPayDiff)),
					totalAmt: Number(_FormatNumber(payTotalInfo.value.memberPayDiff)),
					payAmt: 0,
					payPreAmtRate: _FormatNumber(uni.getStorageSync('cardInfo').currentPresentAmt / uni
						.getStorageSync('cardInfo').currentAmtAct), // 向下取整两位小数
					memberCode: uni.getStorageSync('cardInfo').code,
				});
			} else {
				postForm.payList.push({
					...payListForm,
					payType: "004",
					prePayAmt: payTotalInfo.value.prePayAmt,
					payPreAmtRate: uni.getStorageSync('cardInfo').currentPresentAmt / uni.getStorageSync(
						'cardInfo').currentAmtAct, // 向下取整两位小数
					totalAmt: Number(_FormatNumber(payTotalInfo.value.memberPayDiff)),
					payAmt: Number(_FormatNumber(payTotalInfo.value.memberPayDiff - payTotalInfo.value
						.prePayAmt)),
					memberCode: uni.getStorageSync('cardInfo').code,
				});
			}


		}
		// 微信支付 
		if (payViewList.value[3].checkPay && fee > 0) {
			postForm.payList.push({
				...payListForm,
				payType: "002",
				totalAmt: fee,
				payAmt: fee,
			});
		}
		// 支付宝支付
		if (payViewList.value[2].checkPay && fee > 0) {
			postForm.payList.push({
				...payListForm,
				payType: "003",
				totalAmt: fee,
				payAmt: fee,
			});
		}
		// 升级权益卡
		if (payTotalInfo.value.openVip) {
			postForm.payList.push({
				...payListForm,
				payType: "升级",
				totalAmt: Number(payTotalInfo.value.totalPayVip),
				payAmt: Number(payTotalInfo.value.totalPayVip),
				cardNo: uni.getStorageSync('cardInfo').code,
			});
			payForm.fee = Number(_FormatNumber(Number(payForm.fee) + Number(payTotalInfo.value
				.totalPayVip))) // 和微信支付算一起唤起微信付款
		}
		if (payViewList.value[3].checkPay && payForm.fee > 0) { // 微信买单
			let payRes = await HFiveMemberAppObjProcess({ functionName: "PayOrder_H5", contentData: payForm })
			if (payRes) {
				postForm.payList.filter(item => item.payType === '002' || item.payType == '升级').forEach(item => {
					item.tradeNo = payRes.tradeNo;
				});
				// onBuyLins(postForm); // 临时买单
				HFiveMemberAppObjProcess({
					functionName: 'TemporaryOrderPay_H5',
					contentData: postForm
				}).then(res=>{
					console.log(res);
					uni.hideLoading()
					wxPaySDK(payRes, resultOrder)
					// payFlag.value = false
				}).catch(err=>{
					uni.hideLoading()
					uni.showToast({
						title: "临时买单异常",
						mask: true,
						duration: 2000,
					})
					payFlag.value = false
					uni.reLaunch({
						url: `/pages/order/index` // 跳转到订单详情
					})
				})
				
			}

		} else if (payViewList.value[2].checkPay && payForm.fee > 0) { // 支付宝买单
			let payRes = await HFiveMemberAppObjProcess({ functionName: "AliPayOrder_H5", contentData: payForm })

			if (payRes) {
				if(shopInfo.isOpenUnionPay){ // 如果是银联支付
					uni.hideLoading()
					aliContent.value = payRes.qr_code
					postForm.payList.filter(item => item.payType === '003' || item.payType == '升级').forEach(item => {
						item.tradeNo = payRes.tradeNo;
					});
					cancleForm.value.orderBatchCode = resultOrder.orderBatchCode
					cancleForm.value.tradeNo = payRes.tradeNo
					
					
					// onBuyLins(postForm); // 临时买单
					HFiveMemberAppObjProcess({
						functionName: 'TemporaryOrderPay_H5',
						contentData: postForm
					}).then(res=>{
						uni.hideLoading()
						uni.setStorageSync('payAli', true)
						showAliPay.value = true
						payFlag.value = false
					}).catch(err=>{
						uni.hideLoading()
						uni.showToast({
							title: "临时买单异常",
							mask: true,
							duration: 2000,
						})
						uni.reLaunch({
							url: `/pages/order/index` // 跳转到订单详情
						})
						payFlag.value = false
					})
					
				}else{ // 不是银联支付
					postForm.payList.filter(item => item.payType === '003' || item.payType == '升级').forEach(item => {
						item.tradeNo = payRes.tradeNo;
					});
					
					// onBuyLins(postForm); // 临时买单
					HFiveMemberAppObjProcess({
						functionName: 'TemporaryOrderPay_H5',
						contentData: postForm
					}).then(res=>{
						uni.hideLoading()
						uni.navigateTo({
							url: '/pagesOrder/view/pay/alipay?paymentRes=' + payRes.qr_code + '&from=pay'
						})
						payFlag.value = false
					}).catch(err=>{
						uni.hideLoading()
						uni.showToast({
							title: "临时买单异常",
							mask: true,
							duration: 2000,
						})
						uni.reLaunch({
							url: `/pages/order/index` // 跳转到订单详情
						})
						payFlag.value = false
					})
				}
			}
		} else {
			onBuy(postForm, resultOrder)
		}
	}

	const onBuy = async (postForm, resultOrder) => {

		await HFiveMemberAppObjProcess({
			functionName: 'MemberOrderPay_H5',
			contentData: postForm
		}).then((res) => {
			uni.hideLoading()
			uni.showToast({
				title: "下单成功",
				mask: true,
				duration: 2000,
			})
			clearStoreGoodsNum() // 清空购物车
			setTimeout(() => {
				uni.reLaunch({
					url: `/pages/order/index` // 跳转到订单详情
				})
				payFlag.value = false
			}, 2000)
			// 清空购物车
			// $ClearCart() 
		}).catch((err) => {
			// 处理支付失败的情况
			uni.hideLoading()
			if (orderPayType.value == 'unpay' || orderPayType.value == 'paying') { // 不取消订单
				uni.showToast({
					title: '支付失败',
					mask: true,
					duration: 2000
				})
				setTimeout(() => {
					payFlag.value = false
					uni.navigateBack()
				}, 2000)
				return
			} else {
				HFiveMemberAppObjProcess({
					functionName: "MemberOrderCancel_H5",
					contentData: {
						orderBatchCode: resultOrder.orderBatchCode
					}
				}).then(res => {

					uni.showToast({
						title: '支付失败，已取消订单',
						mask: true,
						duration: 2000
					})
					setTimeout(() => {
						payFlag.value = false
						uni.navigateBack()
					}, 2000)
				})
			}
		})
	}

	const onBuyLins = async (postForm, resultOrder) => {
		await HFiveMemberAppObjProcess({
			functionName: 'TemporaryOrderPay_H5',
			contentData: postForm
		})
		uni.hideLoading()
	}
	
	// --------------------------------------------------------------------------------------------推荐储值----------------------------------------------------------------------------------
	
	const storeProductList = ref([])
	const selectedIndex = ref(null);
	const clickFlag = ref(false)
	const payShow = ref(false)
	const stroePayForm = ref({})
	const getstoreListStatus = ()=> {
		    getProgramme()
	}
	
	// 获取储值方案
	const getProgramme = async ()=> {
	 const cardInfo = uni.getStorageSync('cardInfo')
		 console.log(cardInfo,'cardInfo')
	  let contentData = {
	    typeCode: cardInfo.cardType
	  }
	  if (cardInfo.cardType === 1) {
	    contentData.brandCode = cardInfo.brandCode
	  } else {
	    contentData.brandCode = ''
	  }
	  
	  try {
	  	const res = await HFiveMemberAppObjProcess({
	  	  functionName: "GetNewSchemeList_H5",
	  	  contentData
	  	})
	  
	  // 查找第一个 ChargeAmt 大于 salePriceTotal 的对象
	  let fliter = res.find(item => item.ChargeAmt > payTotalInfo.value.salePriceTotal );
	  	console.log(fliter,'fliter1')
	  // 如果没有找到符合条件的对象，找出 列表 最大的对象
	  if (!fliter) {
	       fliter =  res.sort((a, b) => b.ChargeAmt - a.ChargeAmt)[0];
		console.log(fliter,'fliter2')
	   }
	   
	   storeProductList.value.push(fliter)
	   
	   storeProductList.value.map(item=> {
		      if(item.schemelist.length == 1) {
				    selectedIndex.value = 0
					clickFlag.value = true
			  } else {
				   selectedIndex.value = 0
			  }
	   })
	   console.log(storeProductList.value,'storeProductList：');
	
	  }
	   catch (error) {
	  
	  }
	 
	}
	
	const splitName = (name) => {
	  return name.split('+');  // 根据 + 分割字符串
	};
	
  // 选择商品
	const selectProduct = (index) => {
	  if (clickFlag.value) {
		// 只有一个商品时，不允许取消选中
		return;
	  }
			  
	  // 切换选中的商品
	  if (selectedIndex.value === index) {
		selectedIndex.value = null; // 如果已经选中，点击取消选择
	  } else {
		selectedIndex.value = index;
	  }
	};

	// 立即储值
	const  InstantStored  = ()=> {
		      stroePayForm.value = {
		      	schemeCode:storeProductList.value[0].SchemeCode,
		      	schemeGroup:storeProductList.value[0]?.schemelist[selectedIndex.value]?.SchemeGroup,
		      	// otherCode:'',
		      	memberCode:uni.getStorageSync('cardInfo').code,
		      	referRoomCode:storeTableInfo.value.code,
		      	referRoomName:storeTableInfo.value.name,
		      }
		      console.log(stroePayForm.value,'stroePayForm.value')
		      payShow.value = true
	}
	
	// 立即储值支付
	const confirmPay = async(e)=>{
		console.log(e);
		if(e){
			payShow.value = false
            initCardInfoFun()
		}
	}
   
	
</script>

<style scoped lang="less">
	.uv-content{
		position: relative;
		.uv-content-mask{
			position: absolute;
			background-color: #ffffff;
			z-index: 999;
			.mask-title{
				background-color: #ffffff;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: var(--maincolorf1);
				line-height: 36rpx;
				text-align: center;
				padding-bottom: 20rpx;
			}
			.mask-list{
				background-color: #ffffff;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: var(--maincolorf1);
				line-height: 48rpx;
				max-width: 600rpx;
			}
		}
		.mask-btn{
			position: absolute;
			bottom: 40rpx;
			background-color: #ffffff;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			width: 50%;
			z-index: 999;
			.mask-cancle{
				width: 200rpx;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 36rpx;
				color: var(--dt-colorPink);
				line-height: 80rpx;
				text-align: center;
				padding-left: 20rpx;
			}
		}
		// .ali-return{
		// 	position: absolute;
		// 	left: 0;
		// 	top: 0;
		// 	height: 100%;
		// 	width: 50%;
		// 	background: transparent;
		// }
		::v-deep{
			.pop_tip_p4{
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: var(--maincolorf1);
				line-height: 36rpx;
				text-align: center;
				padding-bottom: 20rpx;
			}
			.pop_tip_p5{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: var(--maincolorf1);
				line-height: 48rpx;
				max-width: 600rpx;
				// padding: 4rpx 0;
			}
			.pop_tip_p3{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 24rpx;
			}
			.p_btn {
				
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 36rpx;
				color: var(--dt-colorPink);
				line-height: 80rpx;
				text-align: center;
			}
			
		}
	}
	
	.chxy-row-ac-end{
		padding: 0 40rpx 0 20rpx;
	}
	.table-view {
		// width: 240rpx;
		padding-left: 26rpx;
		// height: 80rpx;
		// background: var(--mainbaccolor2);
		border-radius: 8rpx;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 28rpx;
		color: var(--maincolorf1);
		line-height: 24rpx;
		margin-right: 28rpx;
		// text-align: center;
	}

	.card-view {
		width: 702rpx;
		margin: 0 24rpx;
		height: 320rpx;
		position: relative;
	}

	.card-name-view {
		position: absolute;
		left: 0;
		top: 0;
		width: 320rpx;
		padding: 10rpx 20rpx 20rpx;
		height: 60rpx;
		background: var(--dt-backcolorPink);
		border-radius: 15rpx 0rpx 24rpx 0rpx;
	}

	.card-left-name {
		width: 340rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: var(--maincolor);
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.card-center-code {
		width: 360rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: var(--maincolorf6);
	}

	.card-right-change {
		width: 180rpx;
		height: 40rpx;
		background: #666666;
		border-radius: 20rpx;
		;
		position: absolute;
		right: 20rpx;
		top: 20rpx;
	}

	.card-change-img {
		margin-left: 20rpx;
		width: 20rpx;
		height: 20rpx
	}

	.card-change-name {
		color: var(--maincolor);
		font-size: 24rpx;
		margin-left: 10rpx;
	}

	.card-vip-view {
		padding: 32rpx 24rpx 0 24rpx;
		width: 654rpx;
		position: absolute;
		bottom: 0;
		left: 0;
		color: var(--maincolor);
		font-size: 24rpx;
	}

	.card-vip-amtact {
		height: 40rpx;
		font-size: 48rpx;
		display: flex;
		align-items: center;
		.amtact-tip{
			font-size: 24rpx;
			padding-left: 20rpx;
			color: #666666;
		}
	}

	.card-vip-item {
		height: 70rpx;
		line-height: 70rpx;
		border-bottom: 1rpx solid #333333;
	}

	.card-item-lable {
		color: var(--maincolorf4);
		display: flex;
		align-items: center;
		.card-send{
			padding-left: 20rpx;
		}
	}

	.card-vip-coins {
		height: 80rpx;
		line-height: 80rpx;
		color: var(--maincolorf4);
	}

	.h40w40 {
		height: 40rpx;
		width: 40rpx;
	}

	.pay-way-title {
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 32rpx;
		color: var(--maincolorf1);
		margin-left: 24rpx;
	}

	.pay-way-view {
		width: 702rpx;
		background: var(--mainbaccolor10);
		border-radius: 16rpx;
		margin: 0 24rpx;
	}

	.pay-gold-cell {
		height: 160rpx;
		border-bottom: 1rpx solid var(--maincolorbd);
		margin: 0 24rpx;
	}

	.gold-cell-img {
		height: 60rpx;
		width: 60rpx;
		margin-right: 24rpx;
	}

	.gold-cell-lable {
		color: var(--maincolorf1);
		font-size: 32rpx;
		font-weight: bold;
	}

	.gold-cell-right {
		color: var(--maincolorf2);
		font-size: 24rpx;
	}

	.gold-right-check {
		margin-left: 50rpx;
	}

	.gold-check-mun {
		color: var(--maincolorf5);
	}

	.pay-amt-cell {
		height: 160rpx;
		margin: 0 24rpx;
		border-bottom: 1rpx solid var(--maincolorbd);
	}

	.amt-img {
		height: 60rpx;
		width: 60rpx;
		margin-right: 24rpx;
	}

	.amt-lable-name {
		color: var(--maincolorf1);
		font-size: 32rpx;
		font-weight: bold;
	}

	.amt-right-view {
		color: var(--maincolorf2);
		font-size: 24rpx;
	}

	.amt-right-check {
		margin-left: 50rpx;
	}

	.amt-check-num {
		color: var(--maincolorf5);
	}

	.pay-ali-cell {
		height: 120rpx;
		margin: 0 24rpx;
		border-bottom: 1rpx solid var(--maincolorbd);
	}

	.ali-cell-img {
		height: 60rpx;
		width: 60rpx;
		margin-right: 24rpx;
	}

	.ali-cell-name {
		color: var(--maincolorf1);
		font-size: 32rpx;
		font-weight: bold;
	}

	.pay-wx-cell {
		height: 120rpx;
		margin: 0 24rpx;
		border-bottom: 1rpx solid var(--maincolorbd);
	}

	.wx-cell-img {
		height: 60rpx;
		width: 60rpx;
		margin-right: 24rpx;
	}

	.wx-cell-name {
		color: var(--maincolorf1);
		font-size: 32rpx;
		font-weight: bold;
	}

	.min-consume-view {
		position: fixed;
		bottom: 208rpx;
		left: 0;
		height: 60rpx;
		color: var(--maincolorf5);
		background: var(--mainbaccolor2);
		width: 100vw;
	}
	
	.min-consuhad-view{
		position: fixed;
		bottom:120rpx;
		left: 0;
		height: 60rpx;
		color: var(--maincolorf5);
		background: var(--mainbaccolor2);
		width: 100vw;
	}

	.pay-view {
		position: fixed;
		bottom: 0;
		left: 0;
		height: 120rpx;
		padding: 0 24rpx;
		width: 702rpx;
		;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		background: var(--mainbaccolor10);
		opacity: 1.0;
		display: flex;
		justify-content: space-between;
	}

	.pay-view-total {
		color: var(--maincolorf5);
		font-size: 36rpx;
		font-weight: bold;
	}

	.pay-view-dif {
		white-space: nowrap;
		color: var(--maincolorf2);
		margin-left: 6rpx;
	}

	.pay-view-vip {
		color: var(--maincolorf2);
		font-size: 24rpx;
	}

	.w180 {
		width: 180rpx;
	}

	.to-pay-but {
		width: 180rpx;
		height: 80rpx;
		background: var(--dt-backcolorPink);
		border-radius: 40rpx;
		margin-left: 20rpx;
		line-height: 80rpx;
		font-size: 32rpx;
		color: var(--maincolor);
		text-align: center;
	}

	.card-yhq-view {
		width: 702rpx;
		background: var(--mainbaccolor10);
		border-radius: 16rpx;
		margin: 0 24rpx;

		.yhq-top-view {
			padding: 30rpx 24rpx 20rpx 24rpx;

			.yhq-top-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 100%;

				.yhq-left {
					display: flex;
					align-items: center;

					.yhj-img {
						width: 60rpx;
						height: 60rpx;
					}

					.yhq-lable-name {
						margin-left: 24rpx;
						color: var(--maincolorf1);
						font-size: 32rpx;
					}
				}

				.yhq-center {
					display: flex;
					align-items: center;

					.center-ticket-total {
						font-size: 24rpx;
						color: var(--maincolorf5);
					}

					.center-desc {
						font-size: 24rpx;
					}

					.center-ticket-num {
						font-size: 24rpx;
						color: var(--maincolorf5);
					}

					.center-img {
						width: 12rpx;
						height: 22rpx;
						margin-left: 12rpx;
					}
				}
			}
		}

		.yhq-list-view {
			height: 60rpx;
			color: var(--maincolorf2);

			.list-name {
				margin-left: 108rpx;
			}

			.list-img {
				width: 18rpx;
				height: 18rpx;
				margin-right: 84rpx;
			}
		}
	}

	.fix-h-288 {
		height: 288rpx;
	}

	.w32h32 {
		height: 32rpx;
		width: 32rpx;
	}

	// 会员卡圆角
	::v-deep {
		.u-image__image {
			border-radius: 12rpx !important;
		}
	}

	.cz-color {
		color: var(--dt-colorPink);
		&.other{
			color:#ff3333
		}
	}
	
	::v-deep .u-textarea {
		height: 50rpx !important;
	}
	
	.tj-containr {
		position: relative;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-bottom: 12rpx;
		padding: 0 24rpx 40rpx 24rpx;
	}
	.poa-text {
		position: absolute;
		left: 0;
		width: 198rpx;
		height: 55rpx;
		background: #FFE9D9;
		border-radius: 15rpx 0rpx 24rpx 0rpx;
		text-align: center;
		line-height: 55rpx;
		font-weight: bold;
		font-size: 30rpx;
		color: #804013;
	}
	.poa-gd {
		padding-top: 10rpx;
		height: 48rpx;
		display: flex;
	    align-items: center;
		float: right;
	}
	.poa-gd-text{
		margin-right: 7rpx;
		font-weight: 500;
		font-size: 24rpx;
		color: #FF3333;
	}
	.store-continar {
		padding: 32rpx 32rpx 24rpx 32rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		border: 2px solid #FFB580;
	}
	.store-flex {
		display: flex;
		align-items: center;
	}
	.store-img {
		width: 80rpx;
		height: 80rpx;
	}
	.store-info {
		 margin-left: 24rpx;
		 flex: 1;
	}
	.store-title {
		  font-weight: bold;
		  font-size: 36rpx;
		  color: #212121;
		  line-height: 48rpx;
		  margin-bottom: 20rpx;
	}
	.store-mark {
		font-weight: 500;
		font-size: 28rpx;
		color: #666666;
		line-height: 30rpx;
	}
	.select-conainr {
		padding: 24rpx;
		margin-top: 24rpx;
		background: #F2F2F2;
		border-radius: 8rpx;
	}
	.se-item-list {
		display: flex;
		align-items: center;
		margin-bottom: 32rpx;
	}
	.se-item-list:nth-last-child(1) {
		margin-bottom: 0;
	}
	.se-icon {
		width: 32rpx;
		height: 32rpx;
	}
	.se-name {
		font-weight: 500;
		font-size: 28rpx;
		color: #212121;
		margin-left: 15rpx;
	}
	.store-btn {
		margin: 40rpx auto 0 auto;
		width: 360rpx;
		height: 80rpx;
		background: linear-gradient(90deg, #FF7140, #FF1200, #FF4E00);
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #FFFFFF;
	}
	.radio-label {
	    line-height: 42rpx;
		font-size: 28rpx;
	}
	.line-break {
	  display: block; /* 使用block使得内容换行 */
	  height: 0; /* 设置高度为0，避免影响布局 */
	}
</style>